import request from '@/utils/httpRequest'

// 商家登录
export async function loginByUserName(params) {
  const res = await request({
    url: '/login/mobile',
    method: 'post',
    data: params || {}
  })
  return res
}

// 商家登录
export async function loginByWechat(params) {
  const res = await request({
    url: '/wx_login',
    method: 'get',
    params: params || {}
  })
  return res
}

export async function bindMobile(params) {
  const res = await request({
    url: '/bindMobile',
    method: 'post',
    data: params || {}
  })
  return res
}

export async function withdraw(params) {
  const res = await request({
    url: '/user/withdraw ',
    method: 'post',
    data: params || {}
  })
  return res
}

// 商家注册
export async function register(params) {
  const res = await request({
    url: '/register',
    method: 'post',
    data: params || {}
  })
  return res
}

// 验证码
export async function getSms(params) {
  const res = await request({
    url: '/sendSms',
    method: 'get',
    params: params || {}
  })
  return res
}
// 忘记密码
export async function forgetPassword(params) {
  const res = await request({
    url: '/forget-password',
    method: 'post',
    data: params || {}
  })
  return res
}

/* 图书模块 */
// 首页接口
export async function getHome(params) {
  const res = await request({
    url: '/home',
    method: 'get',
    params: params || {}
  })
  return res
}
// 首页接口
export async function getArea(params) {
  const res = await request({
    url: '/house/area/' + params.id,
    method: 'get',
    params: params || {}
  })
  return res
}
export async function searchKey(params) {
  const res = await request({
    url: '/book/search-key',
    method: 'get',
    params: params || {}
  })
  return res
}
// 分类列表
export async function getCategory(params) {
  const res = await request({
    url: '/house/app/search',
    method: 'post',
    data: params || {}
  })
  return res
}
// 图书列表
export async function getInfo(params) {
  const res = await request({
    url: '/book/info',
    method: 'get',
    params: params || {}
  })
  return res
}
// 图书列表
export async function getNews(params) {
  const res = await request({
    url: '/information/app/home',
    method: 'get',
    params: params || {}
  })
  return res
}
// 咨询列表
export async function getNewsList(params) {
  const res = await request({
    url: '/information/list',
    method: 'post',
    data: params || {}
  })
  return res
}

// 图书详情
export async function getBookInfo(params) {
  const res = await request({
    url: '/house/app/' + params.id,
    method: 'get',
    params: params || {}
  })
  return res
}
// 图书列表
export async function getSection(params) {
  const res = await request({
    url: '/book/section',
    method: 'get',
    params: params || {}
  })
  return res
}
// 图书列表
export async function getLastSection(params) {
  const res = await request({
    url: `/book/${params.bookId}/section/last`,
    method: 'get',
    params: params || {}
  })
  return res
}
// 图书详情
export async function getSectionInfo(params) {
  const res = await request({
    url: '/book/section/' + params.id,
    method: 'get',
    params: params || {}
  })
  return res
}
// 获取token
export async function getQiNiuToken(params) {
  const res = await request({
    url: '/qiniu/upload-token',
    method: 'get',
    params: params || {}
  })
  return res
}

/** 书架模块 */
// 分页查询
export async function getBookrackList(params) {
  const res = await request({
    url: '/user/bookrack',
    method: 'get',
    params: params || {}
  })
  return res
}
// 新增书架
export async function addBookrack(params) {
  const res = await request({
    url: '/user/bookrack',
    method: 'post',
    data: params || {}
  })
  return res
}
// 查看详情
export async function getBookrack(params) {
  const res = await request({
    url: '/user/bookrack' + params.id,
    method: 'get',
    params: params || {}
  })
  return res
}
// 删除书架
export async function deleteBookrack(params) {
  const res = await request({
    url: '/user/bookrack' + params.id,
    method: 'delete',
    post: params || {}
  })
  return res
}
/** 举报模块 */
// 分页查询
export async function getInformList(params) {
  const res = await request({
    url: '/user/inform',
    method: 'get',
    params: params || {}
  })
  return res
}
// 新增举报
export async function addInform(params) {
  const res = await request({
    url: '/user/inform',
    method: 'post',
    data: params || {}
  })
  return res
}
// 查看举报
export async function getInform(params) {
  const res = await request({
    url: '/user/inform' + params.id,
    method: 'get',
    params: params || {}
  })
  return res
}
// 删除举报
export async function deleteInform(params) {
  const res = await request({
    url: '/user/inform' + params.id,
    method: 'delete',
    params: params || {}
  })
  return res
}
// 阅读记录
export async function readRecord(params) {
  const res = await request({
    url: '/user/read-record',
    method: 'get',
    params: params || {}
  })
  return res
}
export async function readRecordByID(params) {
  const res = await request({
    url: '/user/read-record/' + params.bookId,
    method: 'get',
    params: params || {}
  })
  return res
}

// 收藏夹模块
// 分页
export async function collectionList(params) {
  const res = await request({
    url: '/user/favorite/app/list',
    method: 'post',
    data: params || {}
  })
  return res
}
// 是否
export async function checkedCollection(params) {
  const res = await request({
    url: '/user/favorite/' + params.id,
    method: 'get',
    params: params || {}
  })
  return res
}
// 删除收藏
export async function deleteCollection(params) {
  const res = await request({
    url: '/user/favorite/' + params.houseId,
    method: 'delete',
    data: params || {}
  })
  return res
}
// 增加收藏
export async function addCollection(params) {
  const res = await request({
    url: '/user/favorite?houseId=' + params.houseId,
    method: 'post',
    data: params || {}
  })
  return res
}
// 添加预约
export async function addAppoint(params) {
  const res = await request({
    url: '/user/appoint?houseId=' + params.houseId,
    method: 'post',
    data: params || {}
  })
  return res
}
// 预约列表
export async function appointList(params) {
  const res = await request({
    url: '/user/appoint/app',
    method: 'post',
    data: params || {}
  })
  return res
}
// 添加报备
export async function addReport(params) {
  const res = await request({
    url: '/user/report?houseId=' + params.houseId,
    method: 'post',
    data: params || {}
  })
  return res
}
// 预约列表
export async function reportList(params) {
  const res = await request({
    url: '/user/report/app',
    method: 'post',
    data: params || {}
  })
  return res
}
// 添加报备
export async function addVisit(params) {
  const res = await request({
    url: '/user/visit?houseId=' + params.houseId,
    method: 'post',
    data: params || {}
  })
  return res
}
// 添加报备
export async function addApply(params) {
  const res = await request({
    url: '/user/apply',
    method: 'post',
    data: params || {}
  })
  return res
}
// 预约列表
export async function visitList(params) {
  const res = await request({
    url: '/user/visit/app',
    method: 'post',
    data: params || {}
  })
  return res
}
// 团队列表
export async function teamList(params) {
  const res = await request({
    url: '/user/team',
    method: 'post',
    data: params || {}
  })
  return res
}
// 添加报备
export async function addOrder(params) {
  const res = await request({
    url: '/order?houseId=' + params.houseId,
    method: 'post',
    data: params || {}
  })
  return res
}
// 预约列表
export async function orderList(params) {
  const res = await request({
    url: '/order/app',
    method: 'post',
    data: params || {}
  })
  return res
}
/** 我的相关 */
// 获取我的信息
export async function getUserInfo(params) {
  const res = await request({
    url: '/user/app/detail',
    method: 'get',
    params: params || {}
  })
  return res
}
// 获取我的账户
export async function getUserAccount(params) {
  const res = await request({
    url: '/user/account',
    method: 'get',
    params: params || {}
  })
  return res
}
export async function getTaskDetail(params) {
  const res = await request({
    url: '/task/' + params.id,
    method: 'get'
  })
  return res
}
export async function getUserRecharge(params) {
  const res = await request({
    url: '/account-recharge',
    method: 'get',
    params: params || {}
  })
  return res
}
export async function taskCancel(params) {
  const res = await request({
    url: '/task/cancel/' + params.id,
    method: 'delete'
  })
  return res
}
// 获取我的账户
export async function getUserWithdraw(params) {
  const res = await request({
    url: '/accout/withdraw',
    method: 'get',
    params: params || {}
  })
  return res
}
// 获取我的账户
export async function getUserReward(params) {
  const res = await request({
    url: '/accout/reward',
    method: 'get',
    params: params || {}
  })
  return res
}

/* 收款方式相关 */

// 添加卡号
export async function bankAdd(params) {
  const res = await request({
    url: '/merchant/bank-card/add',
    method: 'post',
    data: params || {}
  })
  return res
}
// 删除店铺
export async function bankDelete(params) {
  const res = await request({
    url: '/merchant/bank-card/delete/' + params.id,
    method: 'get'
  })
  return res
}

// 分页获取店铺
export async function getBankList(params) {
  const res = await request({
    url: '/merchant/bank-card/list',
    method: 'get',
    params: params || {}
  })
  return res
}

// 添加银行卡
export async function addBank(params) {
  const res = await request({
    url: '/user/account/recharge',
    method: 'post',
    data: params || {}
  })
  return res
}
// 充值
export async function addRecharge(params) {
  const res = await request({
    url: '/user/account/recharge',
    method: 'post',
    data: params || {}
  })
  return res
}
// 提现
export async function addWithdraw(params) {
  const res = await request({
    url: '/user/account/withdraw',
    method: 'post',
    data: params || {}
  })
  return res
}
// 查询银行卡
export async function getBank(params) {
  const res = await request({
    url: '/bank-card',
    method: 'get',
    params: params || {}
  })
  return res
}
// 修改银行卡
export async function editBank(params) {
  const res = await request({
    url: '/bank-card',
    method: 'put',
    data: params || {}
  })
  return res
}
// 获取账户变动
export async function getAccountRecord(params) {
  const res = await request({
    url: '/accout/record',
    method: 'get',
    params: params || {}
  })
  return res
}

// 获取账户变动
export async function getWechatSdk(params) {
  const res = await request({
    url: '/wx_info',
    method: 'get',
    params: params || {}
  })
  return res
}

// 获取账户
export async function detailByMobile(params) {
  const res = await request({
    url: '/user/app/detailByMobile',
    method: 'get',
    params: params || {}
  })
  return res
}
